/********************************************************************
	filename: 	Segment2D.h
	created:	2010/04/16
	author:		Xiuwei Chen

	purpose:	Definition of class Segment2D

	All rights Reserved
*********************************************************************/

#pragma once

#include "Const.h"
#include "Vector2D.h"
#include "Line2D.h"

class GEOMETRY_EXPORT Segment2D
{
public:
	/// <Summary>
	/// Zero of LineSeg2D
	/// </Summary>
	const static Segment2D Zero;

	/// <Summary>
	/// start point
	/// </Summary>
	Point2D p0;

	/// <Summary>
	/// end point
	/// </Summary>
	Point2D p1;

	/// <Summary>
	/// default constructor
	/// </Summary>
	Segment2D();

	/// <Summary>
	/// constructor
	/// </Summary>
	Segment2D(const Point2D &_p0, const Point2D &_p1);

	/// <Summary>
	/// constructor
	/// </Summary>
	Segment2D(double x0, double y0, double x1, double y1);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(double x0, double y0, double x1, double y1);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(const Point2D &_p0, const Point2D &_p1);

	/// <Summary>
	/// overload operation: assignment
	/// </Summary>
	Segment2D & operator = (const Segment2D &seg);

	/// <Summary>
	/// overload operation: "=="
	/// </Summary>
	bool operator == (const Segment2D &seg) const;

	/// <Summary>
	/// overload operation: "!="
	/// </Summary>
	bool operator != (const Segment2D &seg) const;

	/// <Summary>
	/// overload operation: unary "-"
	/// </Summary>
	Segment2D operator - () const;

	/// <Summary>
	/// Translation by 2D vector
	/// </Summary>
	void Translation(const Vector2D &v);

	/// <Summary>
	/// Translation by 2D vector
	/// </Summary>
	void Translation(const Vector2D &v0, const Vector2D &v1);
	
	/// <Summary>
	/// get the module of vector (equal to the length)
	/// </Summary>
	double Norm() const;

	/// <Summary>
	/// get the module square of vector (equal to the length)
	/// </Summary>
	double Norm2() const;

	/// <Summary>
	/// Segment Normalize
	/// </Summary>
	void Normalize();

	/// <Summary>
	/// get vertical vector (clockwise direction)
	/// </Summary>
	Vector2D Vertical(bool unit = true) const;

	/// <Summary>
	/// get horizontal vector of 2D line
	/// </Summary>
	Vector2D Horizontal(bool unit = false) const;

	/// <Summary>
	/// rotate counter clockwise around a point (radian)
	/// </Summary>
	void Rotation(const Point2D &center, double angle);

	/// <Summary>
	/// Center
	/// </Summary>
	Point2D Center() const;
};